package com.sam.designpatterns

interface State {
    fun doSomeThing()
}

class WorkingState : State {
    override fun doSomeThing() {
        println("上班：认真工作，积累福报")
    }
}

class OffDutySate : State {
    override fun doSomeThing() {
        println("下班：关注 Android 面试官，学习")
    }
}

// 环境类
class Man {
    private var state: State = OffDutySate()

    fun startWork() {
        state = WorkingState()
    }

    fun offDuty() {
        state = OffDutySate()
    }

    fun doSomeThing() {
        state.doSomeThing()
    }
}

fun main() {
    val man = Man()
    println("打卡上班，这时候做点什么呢")
    man.startWork()
    man.doSomeThing()

    println("到点下班，这时候做点什么呢")
    man.offDuty()
    man.doSomeThing()
}